package com.kgc.ssm.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.kgc.ssm.entity.Contract;
import com.kgc.ssm.entity.ContractExample;
import com.kgc.ssm.entity.dto.Result;
import com.kgc.ssm.mapper.ContractMapper;
import com.kgc.ssm.service.ContractService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 待审批合同处理service实现类
 */

@Service
@Transactional
public class ContractServiceImpl implements ContractService {

    @Autowired(required = false)
    private ContractMapper contractMapper;

    @Override
    public Result<List<Contract>> findPage(Integer pageNum, Integer pageSize) {
        //开始分页
        PageHelper.startPage(pageNum, pageSize);
        //设置条件
        ContractExample example = new ContractExample();
        ContractExample.Criteria criteria = example.createCriteria();
        criteria.andStockTypeEqualTo("S001-20");

        //执行查询
        Page<Contract> page = (Page<Contract>) contractMapper.selectByExample(example);
        return new Result<>("查询成功",200,page.getResult(),page.getTotal());
    }
}
